package com.gmaf.mas.launch;

import java.io.File;
import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class FilePathUtils
{
	private static final Log log = LogFactory.getLog(FilePathUtils.class);
	
	public static String getCanonicalPath(String file)
	{
		return getCanonicalPath(new File(file));
	}
	public static String getCanonicalPath(File file)
	{
		String result = null;
		try
		{
			result = file.getCanonicalPath();
		}
		catch(IOException e)
		{
			log.warn("getCanonicalPath failed for " + file, e);
			result = file.getAbsolutePath();
		}
		return result;
	}
	
	public static File getCanonicalFile(File file)
	{
		File result = null;
		try
		{
			result = file.getCanonicalFile();
		}
		catch(IOException e)
		{
			log.warn("getCanonicalFile failed for " + file, e);
			result = file.getAbsoluteFile();
		}
		return result;
	}
}
